<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.4.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.4.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.4.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.4.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.4.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '7.4.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>


<script data-ad-client="ca-pub-8048531516491146" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

  <meta name="description" content="关于SQLiteSQLite是一个轻量的、跨平台的、开源的数据库引擎，它的在读写效率、消耗总量、延迟时间和整体简单性上具有的优越性，使其成为移动平台数据库的最佳解决方案（如iOS、Android）。 然而免费版的SQLite有一个致命缺点：不支持加密。这就导致存储在SQLite中的数据可以被任何人用任何文本编辑器查看到。比如国内某团购iOS客户端的DB缓存数据就一览无余：">
<meta name="keywords" content="SQLite, sqlcipher">
<meta property="og:type" content="article">
<meta property="og:title" content="加密你的SQLite">
<meta property="og:url" content="http://foogry.org/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/index.html">
<meta property="og:site_name" content="foogry的技术博客">
<meta property="og:description" content="关于SQLiteSQLite是一个轻量的、跨平台的、开源的数据库引擎，它的在读写效率、消耗总量、延迟时间和整体简单性上具有的优越性，使其成为移动平台数据库的最佳解决方案（如iOS、Android）。 然而免费版的SQLite有一个致命缺点：不支持加密。这就导致存储在SQLite中的数据可以被任何人用任何文本编辑器查看到。比如国内某团购iOS客户端的DB缓存数据就一览无余：">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://foogry.org/images/article2/meituan_db_info.png">
<meta property="og:updated_time" content="2019-09-24T12:14:54.775Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="加密你的SQLite">
<meta name="twitter:description" content="关于SQLiteSQLite是一个轻量的、跨平台的、开源的数据库引擎，它的在读写效率、消耗总量、延迟时间和整体简单性上具有的优越性，使其成为移动平台数据库的最佳解决方案（如iOS、Android）。 然而免费版的SQLite有一个致命缺点：不支持加密。这就导致存储在SQLite中的数据可以被任何人用任何文本编辑器查看到。比如国内某团购iOS客户端的DB缓存数据就一览无余：">
<meta name="twitter:image" content="http://foogry.org/images/article2/meituan_db_info.png">
  <link rel="canonical" href="http://foogry.org/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>加密你的SQLite | foogry的技术博客</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?2944231de73b405a5da5c6b4097cfa0e";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
  <div class="container use-motion">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">foogry的技术博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">Stay hungry,stay foolish.</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      <article itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block post">
    <link itemprop="mainEntityOfPage" href="http://foogry.org/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="foogry">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="foogry的技术博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">加密你的SQLite

          
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2014-05-19 10:19:42" itemprop="dateCreated datePublished" datetime="2014-05-19T10:19:42+08:00">2014-05-19</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-09-24 20:14:54" itemprop="dateModified" datetime="2019-09-24T20:14:54+08:00">2019-09-24</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Database/" itemprop="url" rel="index"><span itemprop="name">Database</span></a></span>

                
                
              
            </span>
          

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/#comments" itemprop="discussionUrl"><span class="post-comments-count valine-comment-count" data-xid="/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/" itemprop="commentCount"></span></a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="关于SQLite"><a href="#关于SQLite" class="headerlink" title="关于SQLite"></a>关于SQLite</h2><p>SQLite是一个<code>轻量的</code>、<code>跨平台的</code>、<code>开源的</code>数据库引擎，它的在<code>读写效率</code>、<code>消耗总量</code>、<code>延迟时间</code>和<code>整体简单性上</code>具有的优越性，使其成为移动平台数据库的最佳解决方案（如iOS、Android）。</p>
<p>然而免费版的SQLite有一个致命缺点：不支持加密。这就导致存储在SQLite中的数据可以被任何人用任何文本编辑器查看到。比如国内某团购iOS客户端的DB缓存数据就一览无余：</p>
<img src="/images/article2/meituan_db_info.png" width="700" height="300">

<a id="more"></a>

<h2 id="SQLite加密方式"><a href="#SQLite加密方式" class="headerlink" title="SQLite加密方式"></a>SQLite加密方式</h2><p>对数据库加密的思路有两种：</p>
<ul>
<li>将内容加密后再写入数据库</li>
</ul>
<p>这种方式使用简单，在入库/出库只需要将字段做对应的加解密操作即可，一定程度上解决了将数据赤裸裸暴露的问题。</p>
<p>不过这种方式并不是彻底的加密，因为数据库的表结构等信息还是能被查看到。另外写入数据库的内容加密后，搜索也是个问题。</p>
<ul>
<li>对数据库文件加密</li>
</ul>
<p>将整个数据库整个文件加密，这种方式基本上能解决数据库的信息安全问题。目前已有的SQLite加密基本都是通过这种方式实现的。</p>
<h2 id="SQLite加密工具"><a href="#SQLite加密工具" class="headerlink" title="SQLite加密工具"></a>SQLite加密工具</h2><p>目前网上查询到iOS平台可用的SQLite加密工具有以下几种：</p>
<ul>
<li><a href="http://www.sqlite.org/index.html" target="_blank" rel="noopener">SQLite Encryption Extension (SEE)</a></li>
</ul>
<p>事实上SQLite有加解密接口，只是免费版本没有实现而已。而<code>SQLite Encryption Extension (SEE)</code>是SQLite的加密版本，提供以下加密方式：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">RC4</span><br><span class="line">AES-128 in OFB mode</span><br><span class="line">AES-128 in CCM mode</span><br><span class="line">AES-256 in OFB mode</span><br></pre></td></tr></table></figure>

<p>SQLite Encryption Extension (SEE)版本是收费的。</p>
<ul>
<li><a href="http://www.sqlite-encrypt.com/index.htm" target="_blank" rel="noopener">SQLiteEncrypt</a></li>
</ul>
<p>使用AES加密，其原理是实现了开源免费版SQLite没有实现的加密相关接口。</p>
<p><code>SQLiteEncrypt</code>是收费的。</p>
<ul>
<li><a href="http://sqlite-crypt.com/index.htm" target="_blank" rel="noopener">SQLiteCrypt</a></li>
</ul>
<p>使用256-bit AES加密，其原理和<a href="http://www.sqlite-encrypt.com/index.htm" target="_blank" rel="noopener">SQLiteEncrypt</a>一样，都是实现了SQLite的加密相关接口。</p>
<p><code>SQLiteCrypt</code>也是收费的。</p>
<ul>
<li><a href="http://sqlcipher.net/" target="_blank" rel="noopener">SQLCipher</a></li>
</ul>
<p>首先需要说明的是，<code>SQLCipher</code>是完全开源的，代码托管在<a href="https://github.com/sqlcipher/sqlcipher" target="_blank" rel="noopener">github</a>上。</p>
<p><code>SQLCipher</code>使用256-bit AES加密，由于其基于免费版的SQLite，主要的加密接口和SQLite是相同的，但也增加了一些自己的接口，详情见<a href="http://sqlcipher.net/sqlcipher-api/" target="_blank" rel="noopener">这里</a>。</p>
<p><code>SQLCipher</code>分为收费版本和免费版本，官网介绍的区别为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">easier to setup, saving many steps in project configuration</span><br><span class="line">pre-built with a modern version of OpenSSL, avoiding another external dependency</span><br><span class="line">much faster for each build cycle because the library doesn&apos;t need to be built from scratch on each compile (build time can be up to 95% faster with the static libraries)</span><br></pre></td></tr></table></figure>

<p>只是集成起来更简单，不用再添加<code>OpenSSL</code>依赖库，而且编译速度更快，从功能上来说没有任何区别。仅仅为了上述一点便利去花费几百美刀，对于我等苦逼RD来说太不值了，还好有一个免费版本。</p>
<p>鉴于上述SQLite加密工具中，只有<code>SQLCiper</code>有免费版本，下面将将着重介绍下<code>SQLCiper</code>。</p>
<h2 id="在项目中使用SQLCipher"><a href="#在项目中使用SQLCipher" class="headerlink" title="在项目中使用SQLCipher"></a>在项目中使用SQLCipher</h2><p>在项目中集成免费版的<code>SQLCipher</code>略显复杂，还好官网以图文的方式介绍的非常详细，集成过程请参考<a href="http://sqlcipher.net/ios-tutorial" target="_blank" rel="noopener">官网教程</a>。</p>
<ul>
<li>使用SQLCipher初始化数据库</li>
</ul>
<p>下面这段代码来自官网，其作用是使用SQLCipher创建一个新的加密数据库，或者打开一个使用SQLCipher创建的数据库。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]</span><br><span class="line">                              stringByAppendingPathComponent: @&quot;cipher.db&quot;];</span><br><span class="line">    sqlite3 *db;</span><br><span class="line">    if (sqlite3_open([databasePath UTF8String], &amp;db) == SQLITE_OK) &#123;</span><br><span class="line">        const char* key = [@&quot;BIGSecret&quot; UTF8String];</span><br><span class="line">        sqlite3_key(db, key, strlen(key));</span><br><span class="line">        int result = sqlite3_exec(db, (const char*) &quot;SELECT count(*) FROM sqlite_master;&quot;, NULL, NULL, NULL);</span><br><span class="line">        if (result == SQLITE_OK) &#123;</span><br><span class="line">            NSLog(@&quot;password is correct, or, database has been initialized&quot;);</span><br><span class="line">        &#125; else &#123;</span><br><span class="line">            NSLog(@&quot;incorrect password! errCode:%d&quot;,result);</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        sqlite3_close(db);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>需要注意的是，在使用<code>sqlite3_open</code>打开或创建一个数据库，在对数据库做任何其它操作之前，都必须先使用<code>sqlite3_key</code>输入密码，否则会导致数据库操作失败，报出sqlite错误码<code>SQLITE_NOTADB</code>。</p>
<p>在<code>sqlite3_open</code>打开数据库成功，而且用<code>sqlite3_key</code>输入密码以后，就可以正常的对数据库进行增、删、改、查等操作了。</p>
<ul>
<li>使用SQLCipher加密已存在的数据库</li>
</ul>
<p>SQLCipher提供了<code>sqlcipher_export()</code>函数，该函数可以方便的对一个普通数据库导入到SQLCipher加密加密的数据库中，操作方式如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ ./sqlcipher plaintext.db </span><br><span class="line">sqlite&gt; ATTACH DATABASE &apos;encrypted.db&apos; AS encrypted KEY &apos;testkey&apos;; </span><br><span class="line">sqlite&gt; SELECT sqlcipher_export(&apos;encrypted&apos;); </span><br><span class="line">sqlite&gt; DETACH DATABASE encrypted;</span><br></pre></td></tr></table></figure>

<ul>
<li>解除使用SQLCipher加密的数据库密码</li>
</ul>
<p><code>sqlcipher_export()</code>函数同样可以将SQLCipher加密后的数据库内容导入到未加密的数据库中，从而实现解密，操作方式如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ ./sqlcipher encrypted.db </span><br><span class="line">sqlite&gt; PRAGMA key = &apos;testkey&apos;; </span><br><span class="line">sqlite&gt; ATTACH DATABASE &apos;plaintext.db&apos; AS plaintext KEY &apos;&apos;;  -- empty key will disable encryption</span><br><span class="line">sqlite&gt; SELECT sqlcipher_export(&apos;plaintext&apos;); </span><br><span class="line">sqlite&gt; DETACH DATABASE plaintext;</span><br></pre></td></tr></table></figure>

<p>总体来说，SQLCipher是一个使用方便，灵活性高的数据库加密工具。</p>
<p>另外，我写了个<a href="http://download.csdn.net/detail/wzzvictory_tjsd/7379055" target="_blank" rel="noopener">SQLCipherDemo</a>工程放到了<a href="http://download.csdn.net/detail/wzzvictory_tjsd/7379055" target="_blank" rel="noopener">CSDN</a>上，有需要的同学请自行下载。</p>
<h2 id="参考文档"><a href="#参考文档" class="headerlink" title="参考文档"></a>参考文档</h2><ul>
<li><p><a href="http://www.hwaci.com/sw/sqlite/see.html" target="_blank" rel="noopener">The SQLite Encryption Extension (SEE)</a></p>
</li>
<li><p><a href="http://www.sqlite-encrypt.com/index.htm" target="_blank" rel="noopener">SQLiteEncrypt</a></p>
</li>
<li><p><a href="http://sqlite-crypt.com/index.htm" target="_blank" rel="noopener">SQLiteCrypt</a></p>
</li>
<li><p><a href="http://stackoverflow.com/questions/5669905/sqlite-with-encryption-password-protection" target="_blank" rel="noopener">SQLite with encryption/password protection</a></p>
</li>
<li><p><a href="http://sqlcipher.net/documentation/" target="_blank" rel="noopener">SQLCipher</a></p>
</li>
</ul>

    </div>

    
    
    
        
      
        <div id="reward-container">
  <div></div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="/images/weixinpay.jpg" alt="foogry 微信支付">
        <p>微信支付</p>
      </div>

  </div>
</div>

      
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>foogry</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://foogry.org/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/" title="加密你的SQLite">http://foogry.org/2014/05/19/2014-05-19-jia-mi-ni-de-sqlite/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-ND</a> 许可协议。转载请注明出处！</li>
</ul>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/SQLite/" rel="tag"># SQLite</a>
            
              <a href="/tags/sqlcipher/" rel="tag"># sqlcipher</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/2014/05/09/2014-05-08-xcodeshe-zhi-xiang-zhi-architectureshe-valid-architectures/" rel="next" title="Xcode设置项之Architectures和Valid Architectures">
                  <i class="fa fa-chevron-left"></i> Xcode设置项之Architectures和Valid Architectures
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/2014/05/25/2014-05-25-iosmo-ni-qi-custom-locationbei-zhong-zhi-jie-jue-fang-an/" rel="prev" title="iOS模拟器Custom Location被重置解决方案">
                  iOS模拟器Custom Location被重置解决方案 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="comments"></div>
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
        
        
        
        
      

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#关于SQLite"><span class="nav-number">1.</span> <span class="nav-text">关于SQLite</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SQLite加密方式"><span class="nav-number">2.</span> <span class="nav-text">SQLite加密方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SQLite加密工具"><span class="nav-number">3.</span> <span class="nav-text">SQLite加密工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#在项目中使用SQLCipher"><span class="nav-number">4.</span> <span class="nav-text">在项目中使用SQLCipher</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#参考文档"><span class="nav-number">5.</span> <span class="nav-text">参考文档</span></a></li></ol></div>
        
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">foogry</p>
  <div class="site-description" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">22</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span>
        
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
        <span class="site-state-item-count">56</span>
        <span class="site-state-item-name">标签</span>
        
      </div>
    
  </nav>
  <div class="cc-license motion-element" itemprop="license">
    
  
    <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-nd.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">foogry</span>
</div>
  <div class="powered-by">Hosted by <a href="https://coding.net/pages" class="theme-link" rel="noopener" target="_blank">Coding Pages</a></div>
  <span class="post-meta-divider">|</span>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.4.0</div>

        












        
      </div>
    </footer>
  </div>

  


  <script src="/lib/anime.min.js?v=3.1.0"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/utils.js?v=7.4.0"></script><script src="/js/motion.js?v=7.4.0"></script>
<script src="/js/schemes/pisces.js?v=7.4.0"></script>
<script src="/js/next-boot.js?v=7.4.0"></script>



  





















  

  

  


<script>
NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail,link';
  guest = guest.split(',').filter(item => {
    return GUEST.includes(item);
  });
  new Valine({
    el: '#comments',
    verify: false,
    notify: false,
    appId: 'vqsvFaA8FXndr4867HJvtJ7P-gzGzoHsz',
    appKey: '6L6ddsrLCJVMetc2W7CL9kkf',
    placeholder: 'Comment Here',
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: false,
    lang: 'zh-cn' || 'zh-cn',
    path: location.pathname
  });
}, window.Valine);
</script>

</body>
</html>
